package thread;

public class SyncAPIDemo {
    public static void main(String[] args) {
        //StringBuilder builder = new StringBuilder();
        StringBuffer builder = new StringBuffer();
        Thread t1 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    builder.append("a");
                }
            }
        };
        Thread t2 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    builder.append("b");
                }
            }
        };
        t1.start();
        t2.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {

        }
        System.out.println(builder.length());
    }
}
